#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 33
+#define PIGPIO_VERSION 34
/*TEXT
int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal);
/*D
This writes 16 bits of data to the specified register of the device
-associated with handle and and reads 16 bits of data in return.
+associated with handle and reads 16 bits of data in return.
. .
handle: >=0, as returned by a call to [*i2cOpen*]
cfgMillis:: 100-10000
-The size of the sample buffer in milliseconds. Gnerally this should be
+The size of the sample buffer in milliseconds. Generally this should be
left at the default of 120ms. If you expect intense bursts of signals it
might be necessary to increase the buffer size.
offset::
The associated data starts this number of microseconds from the start of
-tghe waveform.
+the waveform.
*outBuf::
A buffer used to return data from a function.
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include <ctype.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
char command_buf[8192];
char response_buf[8192];
+int printFlags = 0;
+
#define SOCKET_OPEN_FAILED -1
+#define PRINT_HEX 1
+#define PRINT_ASCII 2
+
void fatal(char *fmt, ...)
{
char buf[128];
fflush(stderr);
}
+static int initOpts(int argc, char *argv[])
+{
+ int opt, args;
+
+ args = 1;
+
+ while ((opt = getopt(argc, argv, "ax")) != -1)
+ {
+ switch (opt)
+ {
+ case 'a':
+ printFlags |= PRINT_ASCII;
+ args++;
+ break;
+
+ case 'x':
+ printFlags |= PRINT_HEX;
+ args++;
+ break;
+ }
+ }
+ return args;
+}
+
static int openSocket(void)
{
int sock, err;
void print_result(int sock, int rv, cmdCmd_t cmd)
{
- int i, r;
+ int i, r, ch;
uint32_t *p;
r = cmd.res;
if (r < 0) fatal("ERROR: %s", cmdErrStr(r));
if (r > 0)
{
+ if (printFlags == PRINT_ASCII) printf(" ");
+
for (i=0; i<r; i++)
{
- printf(" %hhu", response_buf[i]);
+ ch = response_buf[i];
+
+ if (printFlags & PRINT_HEX) printf(" %hhx", ch);
+
+ else if (printFlags & PRINT_ASCII)
+ {
+ if ((ch > 31) && (ch < 127)) printf("%c", ch);
+ else printf("\\x%02hhx", ch);
+ }
+ else printf(" %hhu", response_buf[i]);
}
}
printf("\n");
int main(int argc , char *argv[])
{
int sock, command;
- int idx, i, pp, l, len;
+ int args, idx, i, pp, l, len;
cmdCmd_t cmd;
uint32_t p[CMD_P_ARR];
cmdCtlParse_t ctl;
sock = openSocket();
+ args = initOpts(argc, argv);
+
command_buf[0] = 0;
l = 0;
pp = 0;
- for (i=1; i<argc; i++)
+ for (i=args; i<argc; i++)
{
l += (strlen(argv[i]) + 1);
if (l < sizeof(command_buf))
oc = t5_count
while pi.wave_tx_busy():
- time.sleep(0.1)
- time.sleep(0.1)
+ time.sleep(0.2)
+ time.sleep(0.2)
c = t5_count - oc
CHECK(5, 10, c, 1702, 0, "wave tx busy, callback")
oc = t5_count
while pi.wave_tx_busy():
- time.sleep(0.1)
- time.sleep(0.1)
+ time.sleep(0.2)
+ time.sleep(0.2)
c = t5_count - oc
CHECK(5, 32, c, 1702, 0, "wave tx busy, callback")